<template>
	<navbar title="培训"></navbar>
	<view class="parent">
		<view v-for="(item,index) in itemList" class="item">
			<item ref="itemRef" v-if="item.is_show" :Info="item"  :Index="index" @detail="detail(index)"></item>
		</view>
	</view>
	<view class="" style="margin:0rpx 40rpx 40rpx 40rpx;border-radius: 10rpx;height: 376rpx;">
		<image src="https://tx-match.oss-cn-shanghai.aliyuncs.com/image/2024/3/15/16_35_53_916.png" style="border-radius: 10rpx;height: 376rpx;width: 100%;" mode=""></image>
	</view>
	<tabbar :current="1"></tabbar>
</template>

<script setup lang="ts">
	import tabbar from '@/common/tabbar/index.vue'
	import { onLoad, onShow } from '@dcloudio/uni-app'
	import item from './titleItem.vue'
		import { getShow } from '@/service/api/index'
	import tools from '@/utils/tools'
	import { ref, reactive } from 'vue'
	const Info = reactive<InfoType>({
		title: '线上课程',
		subTitle: '诸多好课等你来'
	})
	const is_show = ref(0)
	const itemList = ref([
		{
			title: '线上课程',
			subTitle: '诸多好课等你来',
			is_show:0
		},
		{
			title: '七天速成',
			subTitle: '快速提升能力',
			is_show:1
		},
		{
			title: '城市巡回',
			subTitle: '多城市联动',
			is_show:1
		},
		{
			title: '定制培训',
			subTitle: '根据自身情况定制训练',
			is_show:1
		},
	])
	const itemRef = ref<InstanceType<typeof item>>()
	onShow(()=>{
		show();
	})
	const show = async()=>{
		const {msg} =await getShow("");
		itemList.value[0].is_show = msg;
		console.log(msg);
	}
	const detail = (index : number) => {
		switch (index) {
			case 0:
				tools.navTo('/pagesB/course/index')
				break;
			case 1:
				tools.navTo('/pagesB/speededUp/index')
				break;
			case 2:
				tools.navTo('/pagesB/city/index')
				break;
			case 3:
				tools.navTo('/pagesB/custom/index')
				break;

		}

		console.log('详情');
	}
</script>

<style scoped lang="scss">
	.item {
		margin-bottom: 50rpx;
		margin-top: 20rpx;	
	}
	.parent{
		//margin-bottom: 50rpx;
		:last-child{
			margin-bottom: 0;
		}
	}
</style>